package com.customer.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.customer.dao.ClientMapper;
import com.customer.fegin.WeiXinPayFegin;
import com.customer.service.ClientService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.nameless.entity.Client;
import com.nameless.util.JwtUtil;
import com.nameless.util.WebUtils;
import com.nameless.vo.ClientVo;
import com.nameless.vo.Result;
import com.nameless.vo.pay.RequestParams;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * @author WHZ
 * @date 2023年02月27日 11:22
 */
@Service
public class ClientServiceImpl extends ServiceImpl<ClientMapper, Client> implements ClientService {
   @Autowired
   private ClientMapper clientMapper;

    @Override
    public Result findAll(Integer currentPage, Integer pageSize,ClientVo clientVo) {
        PageHelper.startPage(currentPage,pageSize);
        List<Client> all = clientMapper.findAll(clientVo);
        PageInfo<Client> clientPageInfo = new PageInfo<>(all);
        return new Result(200,"成功",clientPageInfo);
    }

    @Override
    public Result add(Client client) {
//        System.out.println(client+"++++++++++++++++++++++++++++++");
//        String password = client.getPassword();
//        BCryptPasswordEncoder passwordEncoder=new BCryptPasswordEncoder();
//        String encode = passwordEncoder.encode(password);
//        System.out.println("-----------------"+encode);
//        Client client1 = client.setPassword(encode);
//        System.out.println("==================="+client1);
        int insert = clientMapper.insert(client);
        return new Result(200,"添加成功",insert);
    }

    @Override
    public Client getClient(String clientNAme) {
        return clientMapper.getClient(clientNAme);
    }
}
